package cn.unknowpupil.init.domain.system;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDateTime;
import cn.unknowpupil.init.configure.mybatisplus.base.SuperEntity;
import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * Created at 2020-11-13 by  w10g <br>
 * Initialize SysUser  ... <br>
 *  用户信息表
 *
 * @author unknowpupil
 * @since 0.0.1
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sys_user")
@ApiModel(value = "SysUser 域", description = "用户信息表")
public class SysUser extends SuperEntity<SysUser> {

private static final long serialVersionUID=1L;
    /**
     * 部门ID
     */
    @ApiModelProperty(value = "父级ID")
    @TableField(value ="p_id")
    private Long pId;
    /**
     * 用户账号
     */
    @ApiModelProperty(value = "用户账号")
    @TableField(value ="user_name")
    private String userName;
    /**
     * 用户昵称
     */
    @ApiModelProperty(value = "用户昵称")
    @TableField(value ="nick_name")
    private String nickName;
    /**
     * 用户类型（00系统用户）
     */
    @ApiModelProperty(value = "用户类型（00系统用户）")
    @TableField(value ="user_type")
    private String userType;
    /**
     * 用户邮箱
     */
    @ApiModelProperty(value = "用户邮箱")
    @TableField(value ="email")
    private String email;
    /**
     * 手机号码
     */
    @ApiModelProperty(value = "手机号码")
    @TableField(value ="mobile")
    private String mobile;
    /**
     * 用户性别（0男 1女 2未知）
     */
    @ApiModelProperty(value = "用户性别（0男 1女 2未知）")
    @TableField(value ="sex")
    private String sex;
    /**
     * 头像地址
     */
    @ApiModelProperty(value = "头像地址")
    @TableField(value ="avatar")
    private String avatar;
    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    @TableField(value ="password")
    private String password;
    /**
     * 最后登录IP
     */
    @ApiModelProperty(value = "最后登录IP")
    @TableField(value ="login_ip")
    private String loginIp;
    /**
     * 最后登录时间
     */
    @ApiModelProperty(value = "最后登录时间")
    @TableField(value ="last_login_date")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    private Date lastLoginDate;




    public boolean isAdmin() {
        return isAdmin(this.getId());
    }

    public static boolean isAdmin(Long pid) {
        return pid != null && 1L == pid;
    }

}